<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>
	<title>
		<? echo $config['site_name'] ?> | 
		<? 
		if ($template->isSearch()) { 
			echo 'Søgning'; 
		} else if ($template->isPage() && !$template->isPageFound()) { 
			echo "Siden blev ikke fundet"; 
		} else { 
			echo $template->getTitle(); 
		} 
		?>
	</title>
	<meta http-equiv="content-type" content="text/html;charset=utf-8" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<link rel="stylesheet" type="text/css" href="stylesheet/style.css" />
	<script type="text/javascript" src="javascript/prototype.js"></script>
	<script type="text/javascript" src="javascript/misc.js"></script>
	<script type="text/javascript">
		
		function query_url(query) {
			var use_rewrite = <? echo (use_mod_rewrite() == true) ? 'true' : 'false' ?>;
			if (use_rewrite) {
				return encodeURI('q-' + query + '.html');
			}
			return encodeURI('index.php?query=' + query);
		}
		function search(query) {
			document.location.href = query_url(query);
		}
		
	</script>
</head>

<body>
	<div class="header">
		<div class="wrapper">
			<table style="height: 70px; width: 100%" cellspacing="0" cellpadding="0">
				<tr>
					<td>
						<div class="title">
							<a href="<?= page_link($config['site_index'])?>">
								<h1><?= $config['site_name'] ?></h1>
							</a>
						</div>
					</td>
					<td style="vertical-align: top; text-align: right">
						<div class="search">
							<form action="search" method="get" 
							onsubmit="if ($('q').value != '') { search($('q').value); } return false;">
								<input type="text" id="q" name="q" value="Søg" onclick="this.value=''"/>
							</form>
						</div>
					</td>
				</tr>
			</table>
		</div>
	</div>
	<div class="body">
		<div class="wrapper">
			<div class="content">
				<? if ($template->isPage() && $template->isPageFound()) { ?>
					
					<h2 class="page_title"><?= $template->getTitle() ?></h2>
					
					<div class="page_content">
						<?= $template->getText() ?>
					</div>
					
					
					<p class="page_info">
						Skrevet af <?= $template->getAuthor() ?> - <? echo $template->getTimestamp() ?>
					</p>
					
				<? } else if ($template->isSearch()) { ?>
					<div class="page_info"><b>Søgning</b> - søgning på ordet "<? echo $template->getQuery() ?>" - 
						<? echo ($template->getResults() != null) ? count($template->getResults()) : 0 ?> resultat(er)</div>
					<div class="page_info">
					
						<? if ($template->getResults() != null && count($template->getResults()) > 0) { ?>
							<? foreach ($template->getResults() as $r) { ?>
								<div class="UI_PageSearch_Result" 
									onclick="document.location.href='<? echo page_link($r['name']) ?>'"
									style="cursor: pointer">
									<strong><?= $r['title'] ?></strong><br/>
									<?= truncate($r['text'], 100) ?>
								</div>
							<? } ?>
						<? } else { ?>	

						<? } ?>
					</div>
				<? } else { ?>
					<div class="UI_PageNotFound">
						<h3>Siden du søger findes ikke!</h3>
						<a href="<?= page_link($config['site_index']) ?>">Klik her</a> for at gå til forsiden.
					</div>
				<? } ?>
			</div>
			<div class="menu">
				<h2>Menu</h2>
				<ul>
					<? include $template->getPath('menu.php') ?>
				</ul>
			</div>
		</div>
		
		<div class="footer wrapper">
			<small><a href="admin">Admin</a> | Powered by <b>KomitCMS <? echo VERSION ?></b> &copy 2009 Jacob Friis Pedersen</small>
		</div>
	</div>
</body>
</html>